﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TextEditApp.Algorithm;
namespace TextEditApp.Forms
{
    public partial class ReplaceForm : Form
    {
        public ReplaceForm()
        {
            InitializeComponent();
        }

        private void tbx_replaceNext_Click(object sender, EventArgs e)
        {
            Main mainForm = (Main)this.Owner;
            string findStr = tbx_find.Text;
            string replaceStr = tbx_replace.Text;
            string text = mainForm.tbx_main.Text;
            if (text.Contains(findStr))
            {
                mainForm.tbx_main.Text = text.Replace(findStr, replaceStr);
                mainForm.Focus();
            }
        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void ReplaceForm_Load(object sender, EventArgs e)
        {
            AnotherDictionary d = AnotherDictionary.GetDictionary;
            tbx_find.AutoCompleteCustomSource.AddRange(d.GetWords());
            tbx_find.AutoCompleteMode = AutoCompleteMode.Suggest;
            tbx_find.AutoCompleteSource = AutoCompleteSource.CustomSource;
            tbx_replace.AutoCompleteCustomSource.AddRange(d.GetWords());
            tbx_replace.AutoCompleteMode = AutoCompleteMode.Suggest;
            tbx_replace.AutoCompleteSource = AutoCompleteSource.CustomSource;
        }
    }
}
